package com.kaoshi.T24;

import java.util.Scanner;

/**
 * @author xiyu
 * @version 1.0
 * @date 2025/4/7 15:38
 * @description
 */
public class Test {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入用户名：");
        String name = input.next();
        String jieguo = hefa(name);
        if (jieguo==null){
            System.out.println("用户名合法");
        }else {
            System.out.println(jieguo);
        }

    }

    public static String hefa(String name) {
        if (name.isEmpty()){
            return "用户名不能为空";
        }
        if (name.length()<=6){
            return "用户名长度必须大于6";
        }
        char[] chars = name.toCharArray();
        boolean flag = false;
        for (char c : chars) {
            if (c>=48&&c<=57){
                flag = true;
            }
        }
        if (flag){
            return "用户名中不能有数字";
        }
        return null;
    }

}
